import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import routes from './router'
import store from './store'
import axios from 'axios'
import Loading from './components/loading'
Vue.use(VueRouter);
Vue.use(Loading)
/*关于aixos配置*/
//发送请求
axios.interceptors.request.use(function (config) {
    store.dispatch('showLoading');
    return config;
},function (error) {
    return Promise.reject(error)
})

//数据返回
axios.interceptors.response.use(function (response) {
    store.dispatch('hideLoading');
    return response;
},function (error) {
    return Promise.reject(error)
})

Vue.prototype.$http =axios //把axios对象挂载到vue的原型对象上使每个页面都能用this.$http调用发送请求

const router = new VueRouter({
    mode:'history',
    routes,
    scrollBehavior : ( ) => ({ y: 0 }), // 滚动条滚动的行为，不加这个默认就会记忆原来滚动条的位置
})
require('./assets/css/base.css')
new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App)
})
